#!/usr/bin/env python
import urllib2

# ingest csv of extents and build up pylot testcase

WMS_REQUEST_SANS_BBOX = "http://tile2.dbsgeo.com/?layers=__all__&amp;request=GetMap&amp;service=WMS&amp;styles=''&amp;format=image/png8&amp;srs=EPSG:4326&amp;width=499&amp;height=500"
url = urllib2.unquote(WMS_REQUEST_SANS_BBOX)
url = url.replace('&','&amp;')

header =  '''
<testcases>'''

# &amp;bbox=-72.2487028,18.6991997,-71.9878771,18.9460767

case = '<case><url>' + url + '&amp;bbox=%s,%s,%s,%s</url></case>'

footer = '''</testcases>'''

def cases(extents):
    for line in open(extents,'rb'):
        bbox = line.strip()
        if bbox:
            print case % tuple(bbox.split(','))

print header
cases('extents.csv')
print footer